﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Data;

namespace ImportDB
{
    class CSVFile:PlainDataFileBase, IPlainDataFile
    {
        private string fileName;

        public CSVFile(string fileName)
        {
            // TODO: Complete member initialization
            this.fileName = fileName;
        }

        #region IPlainDataFile Members

        public System.Data.DataTable GetDataTable()
        {
            string filepath = System.IO.Path.GetDirectoryName(this.fileName);
            string connectionString = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" + filepath + "; Extended Properties=\"text;HDR=Yes;FMT=Delimited\"";
            string sql = string.Format("select * from [{0}]", System.IO.Path.GetFileName(this.fileName));
            return GetTable(connectionString, sql);
        }

        #endregion
    }
}
